package com.xtravel.discovery.adapter;

import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import com.lidroid.xutils.BitmapUtils;
import java.util.List;
import com.xtravel.common.adapter.BaseDataAdapter;
import com.xtravel.common.helper.ShareSdkHelper;
import com.xtravel.discovery.dto.LiveRecord;
import com.xtravel.discovery.viewholder.LiveRecordsViewHolder;
import com.xtravel.discovery.viewholder.BaseViewHolder;

/**
 * Created by Memory on 15/11/4.
 */

//All/国家Adapter
public class LiveRecordsAdapter extends BaseDataAdapter<LiveRecord> {
    private Context context;
    private LayoutInflater layoutInflater;
    private BitmapUtils bitmapUtils;
    private int imgWidth;

    public LiveRecordsAdapter(Context context, List<LiveRecord> items, BitmapUtils bitmapUtils)
    {
        super(items);
        this.context = context;
        this.bitmapUtils = bitmapUtils;
        layoutInflater = LayoutInflater.from(this.context);
        DisplayMetrics dm = new DisplayMetrics();
        WindowManager wm = ((Activity) context).getWindowManager();
        int width = wm.getDefaultDisplay().getWidth();
        float density = context.getResources().getDisplayMetrics().density;
        imgWidth = (int) (width - 24 * density);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        BaseViewHolder holder;
        if (convertView == null) {
            holder = new LiveRecordsViewHolder(this.context, this.bitmapUtils, this.layoutInflater, imgWidth);
            convertView = holder.getView();
        } else {
            holder = (BaseViewHolder) convertView.getTag();
        }

        LiveRecord record = getItem(position);
        holder.setValue(record);
        return convertView;
    }

    @Override
    public void getData(Object args) {

    }

    @Override
    protected void updateData(List<LiveRecord> data) {

    }
}

